package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;


// ***************************************************************************
// *** CLASS: Stige
// ***************************************************************************
public class Stige extends Block
{ 
  public Stige
  (String ident,Point3D p0,double width,double height,double depth)
  { super(ident,p0,width,height,depth);
  }
    
  
  // ***************************************************************************
  // *** METHOD: getModel3D -- TEMP !!!
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  { 
    return(null);
  }  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { Rectangle2D.Double r=projection(direction,origo2D,scale);
    switch(direction)
    {
//      case NORTH: tegnStigeFasade(g,r,scale,c); break;
//      case SOUTH: tegnStigeFasade(g,r,scale,c); break;
//      case EAST: tegnStigeFasade(g,r,scale,c); break;
//      case WEST: tegnStigeFasade(g,r,scale,c); break;
//      case ABOVE: drawProjectionAbove(g,r,scale,c); break;
//      case BELOW: drawProjectionBelow(g,r,scale,c); break;
      case VCUT: drawVerticalCut(g,r,scale,c); break;
      case HCUT: drawHorisontalCut(g,r,scale,c); break;
      default: super.drawProjection(direction,g,origo2D,scale,c);
    }  
  }
      
  private void drawHorisontalCut(Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { fill(g,r,Color.white);
    draw(g,r);
    double dy=r.height/10;
    drawLine(g,r.x+r.width/2,r.y,r.x+r.width/2,r.y+r.height);
    drawLine(g,r.x+r.width/2,r.y,r.x,r.y+2*dy);
    drawLine(g,r.x+r.width/2,r.y,r.x+r.width,r.y+2*dy);
    for(int i=0;i<10;i++)
      drawLine(g,r.x,r.y+i*dy,r.x+r.width,r.y+i*dy);
  }

  private void drawVerticalCut
  (Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { double th=0.17*scale;
    GeneralPath stige=new GeneralPath();
    stige.moveTo((float)(r.x),(float)(r.y+r.height-th));
    stige.lineTo((float)(r.x),(float)(r.y+r.height));
    stige.lineTo((float)(r.x+r.width),(float)(r.y+th));
    stige.lineTo((float)(r.x+r.width),(float)(r.y));
    stige.lineTo((float)(r.x),(float)(r.y+r.height-th));
    fill(g,stige,c);
    draw(g,stige);
  }
  
//  private void tegnStige(Graphics g)
//  { double x=240-120-10;
//    double y=300-stokk.width-50;
//    double width=60+120+20;
//    double height=50;
//    fillRect(g,x,y,width,height,Color.white);
//    drawRect(g,x,y,width,height);
//    for(int i=0;i<10;i++)
//      drawLine(g,x+i*20,y,x+i*20,y+height);
//  }  

}